const {resolve} = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  entry: './src/index.js',
  output: {
    path: resolve(__dirname, 'build'),
    filename: "bundle.js"
  },
  module: {
    rules: [
      {
        test: /\.css$/, use: ['styles-loader', 'css-loader']
      },
      {
        test: /\.(jpg|jpeg|png|gif)$/, loader: 'url-loader',
        options: {
          limit: 8 * 1024
        }
      },
      {
        exclude: /\.(html|css|js)/,  // 排除一些资源
        loader: 'file-loader'
      }
    ]
  },
  plugins: [
    new htmlWebpackPlugin({
      template: "./src/index.html"
    })
  ],
  mode: "development",
  // 开发服务器  command:npx webpack-dev-server
  devServer: {
    contentBase: resolve(__dirname, 'build'),
    compress: true,
    port: 9000,
    open: true
  }
}